home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
util
/
cli
/
linkdir_source.lha
/
linkdir.asm
< prev
next >
Wrap
Assembly Source File
|
1997-05-09
|
6KB
|
369 lines
_execbase equ 4
openlib equ -552
closelib equ -414
allocmem equ -198
freemem equ -210
lock equ -84
unlock equ -90
examine equ -102
exnext equ -108
open equ -30
close equ -36
read equ -42
write equ -48
delay equ -198
currentdir equ -126
move.l a0,caddress ;save commandline
move.l d0,clength
movem.l a0-a6/d0-d7,-(sp)
move.l _execbase,a6 ;open doslib
moveq #0,d0
move.l #dosname,a1
jsr openlib(a6)
move.l d0,dosbase
beq end
move.l #200,d0 ;alloc mem for dirname
moveq #0,d1
jsr allocmem(a6)
move.l d0,dirname
beq closel
move.l #200,d0 ;alloc mem for linkedline (19+filename)
moveq #0,d1
jsr allocmem(a6)
move.l d0,linkedline
beq freeram
move.l #260,d0 ;alloc mem for fileinfoblock
moveq #0,d1
jsr allocmem(a6)
move.l d0,fileinfoblock
beq freeram1
move.l dosbase,a6
move.l #1005,d2 ;open messagewindow
move.l #messagewindow,d1
jsr open(a6)
move.l d0,mwhandle
beq freeram2
move.l mwhandle,d1 ;write welcome
move.l #welcome,d2
move.l #welle,d3
jsr write(a6)
move.l caddress,a0
move.l dirname,a1
copyloop:
move.b (a0),d0
cmp.b #",",d0
beq loopend
cmp.b #10,d0
beq enodir
move.b (a0)+,(a1)+
bra copyloop
loopend:
move.b #0,(a1)
move.l a0,lfadd
lockdir:
move.l dirname,d1
move.l #1005,d2
jsr lock(a6)
move.l d0,dirlock
beq elockdir
move.l dirlock,d1
jsr currentdir(a6)
move.l d0,olddirlock
move.l #linkfilename,a1
move.l lfadd,a0
add.l #1,a0
move.l #29,d0
copylinkfilename:
move.b (a0),d1
cmp.b #10,d1
beq clfnend
move.b (a0)+,(a1)+
dbra d0,copylinkfilename
clfnend:
cmp.l #29,d0
beq standardlfn
back:
move.b #0,(a1)
move.l #linkfilename,d1
move.l #1006,d2
jsr open(a6)
move.l d0,lfhandle
beq elinkfile
move.l lfhandle,d1
move.l #startblock,d2
move.l #sbl,d3
jsr write(a6)
examinedir:
move.l dirlock,d1
move.l fileinfoblock,d2
jsr examine(a6)
move.l fileinfoblock,a0
add.l #8,a0
move.l #29,d0
move.l #filename,a1
filenamecopy1:
move.b (a0)+,(a1)+
dbeq d0,filenamecopy1
move.b #0,(a1)
move.l #29,d1
sub.l d0,d1
move.l d1,lfl
bsr insert
bsr show
examinenext:
move.l dirlock,d1
move.l fileinfoblock,d2
jsr exnext(a6)
cmp.l #0,d0
beq writefile
move.l fileinfoblock,a0
add.l #8,a0
move.l #29,d0
move.l #filename,a1
filenamecopy:
move.b (a0)+,(a1)+
dbeq d0,filenamecopy
move.b #0,(a1)
move.l #29,d1
sub.l d0,d1
move.l d1,lfl
bsr insert
bsr show
bra examinenext
writefile:
move.l lfhandle,d1
move.l #endblock,d2
move.l #ebl,d3
jsr write(a6)
exit:
move.l mwhandle,d1 ;put exit message
move.l #goodby,d2
move.l #goodbyl,d3
jsr write(a6)
move.l olddirlock,d1
jsr currentdir(a6)
closemw:
btst #6,$bfe001
bne closemw
move.l mwhandle,d1 ;close messagewindow
jsr close(a6)
unlockdir:
move.l dirlock,d1
jsr unlock(a6)
cloself:
move.l lfhandle,d1
jsr close(a6)
freeram2:
move.l _execbase,a6
move.l fileinfoblock,a1
move.l #260,d0
jsr freemem(a6)
freeram1:
move.l _execbase,a6
move.l linkedline,a1
move.l #200,d0
jsr freemem(a6)
freeram:
move.l _execbase,a6
move.l dirname,a1
move.l #200,d0
jsr freemem(a6)
closel:
move.l dosbase,a1
jsr closelib(a6)
end:
movem.l (sp)+,a0-a6/d0-d7
rts
insert:
btst #6,$bfe001
beq closemw
move.l lfhandle,d1
move.l #lineblocka,d2
move.l #lbal,d3
jsr write(a6)
move.l lfhandle,d1
move.l #filename,d2
move.l lfl,d3
jsr write(a6)
move.l lfhandle,d1
move.l #bracket,d2
move.l #2,d3
jsr write(a6)
move.l lfhandle,d1
move.l #filename,d2
move.l lfl,d3
jsr write(a6)
move.l lfhandle,d1
move.l #lineblockb,d2
move.l #lbbl,d3
jsr write(a6)
rts
show:
move.l mwhandle,d1
move.l #filename,d2
move.l #30,d3
jsr write(a6)
move.l mwhandle,d1
move.l #nextt,d2
move.l #nexttl,d3
jsr write(a6)
move.l #31,d0
move.l #filename,a0
clearfilename:
move.b #0,(a0)+
dbra d0,clearfilename
rts
standardlfn:
move.l #"inde",(a1)+
move.l #"x.ht",(a1)+
move.w #"ml",(a1)+
bra back
elockdir:
move.l mwhandle,d1
move.l #etlockdir,d2
move.l #etllockdir,d3
jsr write(a6)
bra closemw
enodir:
move.l mwhandle,d1
move.l #etnodir,d2
move.l #etlnodir,d3
jsr write(a6)
bra closemw
elinkfile:
move.l mwhandle,d1
move.l #etlinkfile,d2
move.l #etllinkfile,d3
jsr write(a6)
bra closemw
dosname:
dc.b "dos.library",0
cnop 0,4
dosbase:
dc.l 0
clength:
dc.l 0
caddress:
dc.l 0
dirlock:
dc.l 0
fileinfoblock:
dc.l 0
filehandle:
dc.l 0
filerror:
dc.b "Error on diskaccess !",10,0
filerrorl equ *-filerror
cnop 0,4
welcome:
dc.b "Welcome to LinkDir... !",10,10,0
welle equ *-welcome
cnop 0,4
messagewindow:
dc.b "RAW:30/50/320/190/"," ",126,"LinkDir",126," ...... June 1996 © by Gregor Erz",0
cnop 0,4
mwhandle:
dc.l 0
goodby:
dc.b 10,10,"Thank you for using ... hope to see you again !",10,"Click.",0
goodbyl equ *-goodby
cnop 0,4
etlockdir:
dc.b "Error locking directory !",10,0
etllockdir equ *-etlockdir
cnop 0,4
etnodir:
dc.b "Error: unspecified directory or comma between ",10,"directory and filename missing !",10,0
etlnodir equ *-etnodir
cnop 0,4
etlinkfile:
dc.b "Error creating linkfile !",10,0
etllinkfile equ *-etlinkfile
cnop 0,4
startblock:
dc.b "<html>",10,"<head>",10,"<title>",10,"Linked with LinkDir © June 1996 by Gregor Erz",10,"</title>",10,"</head>",10,"<Body><hr>Simply click on filenames ... Done with LinkDir © Gregor Erz<hr><br><br><br>",10
sbl equ *-startblock
cnop 0,4
endblock:
dc.b "</body>",10,"</html>",0
ebl equ *-endblock
cnop 0,4
linkedline:
dc.l 0
lllength:
dc.l 0
lineblocka:
dc.b "<A HREF=",34
lbal equ *-lineblocka
cnop 0,4
lineblockb:
dc.b "</A><BR>",10
lbbl equ *-lineblockb
cnop 0,4
bracket:
dc.b 34,">"
cnop 0,4
filename:
ds.b 32
dirname:
dc.l 0
nextt:
dc.b " ...",10,0
nexttl equ *-nextt
cnop 0,4
linkfilename:
ds.b 32
lfhandle:
dc.l 0
olddirlock:
dc.l 0
lfadd:
dc.l 0
lfl:
dc.l 0